#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define num 100
char exchange(char *p);
char str_all[num],*ch;

int main()
{
	char str[num],ch;
	int n,i;
	
	scanf("%d",&n);
	char *p[n];
    //定义指针数组
	
	for(i=0; i<=n-1; i++)
	{
		scanf("%s", str);
		p[i]=(char*)malloc(100);
		strcpy(p[i], str);
        //动态分配数组空间，并且将输入的字符串存入数组中
	}
	for(i=0; i<=n-1; i++)
	{
		exchange(p[i]);
        //调用函数进行字符串的颠倒交换
		puts(str_all);
        //输出颠倒交换后的字符串
		free(p[i]);
        //释放动态空间
	}
	
	return 0;
}

char exchange(char *p)
{
	int count=0,i;
	while(*p!='\0')
	{
		p++;
		count++;
	}
	
	p--;
	
	for(i=0; i<=count-1; i++)
	{
		str_all[i]=*p;
		p--;
	}
	
	str_all[count]='\0';
	ch=str_all;
	
	return *ch;
}
